//
//  ImaController.m
//  HappyTravel
//
//  Created by Apple on 2018/8/2.
//  Copyright © 2018年 Apple. All rights reserved.
//

#import "ImaController.h"

@interface ImaController ()


@property(nonatomic, copy)NSArray *  noteHomeDrop;
@property(nonatomic, assign)CGFloat  ima;
@property(nonatomic, assign)NSInteger  placeholder;
@property(nonatomic, assign)int  tatisticsTralvel;

/**
 *  设置之前选中的按钮
 */
@property (nonatomic, weak) UIButton *selectedBtn;

@end

@implementation ImaController

-(NSArray *)becomeChange:(NSString *)show {
     CGFloat ingleton = 4214.0;
    NSMutableArray * contagiousSpat = [NSMutableArray arrayWithCapacity:737];
    ingleton -= 20;
    [contagiousSpat addObject: @(ingleton)];

    return contagiousSpat;

}





- (void)viewDidLoad {

         NSArray * negotiable = [self becomeChange:@"nonviolent"];

      [negotiable enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
          if (idx > 1) {
              NSLog(@"flow:%@", obj);
        }
      }];



    [super viewDidLoad];
    
}

- (void)lineView{
    
    NSArray *normalArray = [NSArray array];
    NSArray *selectedArray = [NSArray array];
    
    normalArray = @[@"defineTable",@"barLaunch",@"loginNomal"];
    selectedArray = @[@"fangkuangInfoTongjitiao",@"photosStartUblish",@"centerLoginNews"];
    
    for (int i = 0; i < 3; i ++) {
        
        UIButton *btn = [UIButton buttonWithType:(UIButtonTypeCustom)];
        
        NSString *imageName = normalArray[i];
        NSString *imageNameSel = selectedArray[i];
        
        [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:imageNameSel] forState:UIControlStateSelected];
        
        CGFloat x = i * self.tabBar.bounds.size.width / 3;
        btn.frame = CGRectMake(x, 0, self.tabBar.bounds.size.width / 3, self.tabBar.bounds.size.height);
        [self.tabBar addSubview:btn];
        
        btn.tag = i+100;
        [btn addTarget:self action:@selector(textChanged:) forControlEvents:UIControlEventTouchUpInside];
        if (i == 0) {
            btn.selected = YES;
            self.selectedBtn = btn;
        }
    }
}

- (void)viewWillLayoutSubviews {
    [super viewWillLayoutSubviews];
    
    for (UIView *view in self.tabBar.subviews) {
        if ([view isKindOfClass:NSClassFromString(@"UITabBarButton")]) {
            [view removeFromSuperview];
        }
    }
}

-(NSString *)touchesBtn:(NSDictionary *)pageFour heightContent:(NSDictionary *)heightContent february:(NSString *)february {
    NSString *bird = [NSString new];

    return bird;

}

- (void)setupTabBar{

         NSString * realization = [self touchesBtn:[NSDictionary dictionaryWithObjectsAndKeys:@"expropriate",@(651), @"interlocutor",@(277), nil] heightContent:[NSDictionary dictionaryWithObjectsAndKeys:@"paleolithic",@(277), @"beg",@(340), @"egotist",@(800), nil] february:@"divinity"];

      if ([realization isEqualToString:@"array"]) {
              NSLog(@"%@",realization);
      }



    for (UIView *view in self.tabBar.subviews) {
        [view removeFromSuperview];
    }
    
    [self lineView];
}

-(UILabel *)drawSingleRight:(float)reeField {
    UILabel * rubbleCovenant = [UILabel new];
    rubbleCovenant.text = @"";
    rubbleCovenant.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha: 0];
    rubbleCovenant.font = [UIFont systemFontOfSize:16];
    rubbleCovenant.textAlignment = NSTextAlignmentLeft;
    rubbleCovenant.frame = CGRectMake(273, 31, 0, 0);
    rubbleCovenant.alpha = 0.2;
    rubbleCovenant.backgroundColor = [UIColor colorWithRed:156 / 255.0 green:194 / 255.0 blue:162 / 255.0 alpha:0.8];

    return rubbleCovenant;

}






- (void)textChanged:(UIButton *)button {

         UILabel * treasurerLark = [self drawSingleRight:9360.0];

      [self.view addSubview: treasurerLark];



    NSInteger tag = button.tag - 100;
    
    if (button.tag == self.selectedBtn.tag) {
        return;
    }
    
    if (tag == 0 || tag == 1 || tag == 2) {
        
        self.selectedBtn.selected = NO;
        button.selected = YES;
        
        self.selectedBtn = button;
        
        if (tag == 2) {
            self.selectedIndex = 2;
        }else if (tag == 1){
            self.selectedIndex = 1;
        }else {
            self.selectedIndex = tag;
        }
    }
}

@end
